// import { ResPage } from "@/api/interface/index";
import { LogTree, Log } from "@/api/interface/logManagement";
import { BASE } from "@/api/config/servicePort";
import http from "@/api";
import { ResPage } from "@/api/interface";

/**
 * @name 用户管理模块
 */

// 日志树模块接口
export const getTreeList = () => {
  return http.get<LogTree.ResTreeList[]>(BASE + `/log/logmodel_tree/`);
};

// 系统日志接口
export const getLogList = params => {
  return http.get<ResPage<Log.ResLogList>>(BASE + `/log/`, params);
};

// 搜索表单条件查询
export const getSearchConfig = () => {
  return http.get<any>(BASE + `/log/filter_elements/`);
};

// 多云管理日志接口
export const getCloudLogList = params => {
  const filters = Object.fromEntries(
    Object.entries(params).filter(([key]) => key != "page" && key != "page_size" && key != "startTime" && key != "endTime")
  );
  const data = {
    Filters: filters,
    Limit: params["page_size"],
    Offset: (params["page"] - 1) * params["page_size"],
    Paged: true
  };
  params.startTime ? (data["startTime"] = params.startTime) : null;
  params.endTime ? (data["endTime"] = params.endTime) : null;
  return http.post<ResPage<Log.ResCloudLogList>>(BASE + `/log/cloud_platform/`, data);
};

// 搜索表单条件查询
export const getData = (url, params) => {
  return http.get<any>(`${url}`, params);
};

// 获取云平台日志详情
export const getCloudLogDetail = params => {
  return http.post(BASE + `/log/cloud_platform_detail/`, params);
};
